<?php

namespace App\Models\Game;

use Illuminate\Database\Eloquent\Model;
class GameMallGoods extends Model
{
    protected $table = "log_role_mall";
    public function __construct(array $attributes = [])
    {
        global $gameArea; if (!$gameArea) $gameArea = 0;
        $this->setConnection('log_'.$gameArea);
        parent::__construct($attributes);
    }

    // 在查询结果中修改 serverid
    public static function updateServerIdInResults($results, $gameArea)
    {
        foreach ($results as $result) {
            $result->serverid = $gameArea; // 将 serverid 修改为传入的 gameArea 值
        }
        return $results;
    }

    //  public function __construct(array $attributes = [])
    // {

    //    global $gameArea;  if (!$gameArea) $gameArea = 0;
    //    global $datakey;  if (!$datakey) $datakey = "rpg_gamedata";

    //     parent::__construct($attributes);
    // 访问 $datakey 全局变量

    // }


}
